<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "/common/header.ftl">
    <title>奖券管理</title>
</head>
<body>

<div id="lotteryTicketDataGrid" style="width:100%;"/>
<div id="toolBar">
    <table style="width:80%;height:110px;">
        <tr>
        	<td align="right">奖池Id号:</td>
            <td>
                <input type="text" id="id" class="easyui-validatebox"/>
            </td>
            <td align="right">奖池标题:</td>
            <td>
                <input type="text" id="ltTitle" class="easyui-validatebox"/>
            </td>
            <td align="right">奖池类型:</td>
            <td>
                <select name="status" id="ltType" class="easyui-combobox" data-options="panelHeight:'auto',editable:false,required:true">
             	   <option value="">请选择</option>
                   <option value="1">实物券</option>
                   <option value="2">红包</option>
                   <option value="3">加息券</option>
                   <option value="4">体验券</option>
                   <option value="5">费用抵用券</option>
                   <option value="6">三方红包</option>
                   <option value="7">现金红包</option>
                   <option value="13">免息券</option>

                   <!-- <option value="9">票券</option>
                   <option value="10">虚拟现金红包</option>
	               <option value="11">返点现金红包</option>
                   <option value="8">直抵券</option>-->
                   <option value="12">积分券</option> 
                </select>
            </td>
            <td align="right">奖池状态:</td>
            <td>
                <select name="status" id="ltStatus"  class="easyui-combobox" data-options="panelHeight:'auto',editable:false,required:true">
             	   <option value="">请选择</option>
                   <option value="1">生效</option>
                   <option value="2">失效</option>
                </select>
            </td>
            <td align="right">建立时间从:</td>
            <td>
                <input type="text" id="createStartTime" class="easyui-datetimebox"/>
            </td>
            <td align="right">至:</td>
            <td>
                <input type="text" id="createEndTime" class="easyui-datetimebox"/>
            </td>
         </tr>
         <tr>
            <td colspan="4">
                 <center>
                 	<shiro:hasPermission name="H01">
                 		<shiro:hasPermission name="H0102">
	                 	 	<shiro:hasPermission name="H010201">
                 				<a href="#" id="add_lotteryTicket" class="easyui-linkbutton"  iconCls="icon-add" >新建</a>
                 			</shiro:hasPermission>
	                 	 	<shiro:hasPermission name="H010202">
	                 	 		<a href="#" id="searchLink" class="easyui-linkbutton" iconCls="icon-search">查询</a>
	                 	 	</shiro:hasPermission>
                 			<#--<%-- <shiro:hasPermission name="H010203">
                 				<a href="#" onclick="delLink()" class="easyui-linkbutton"  iconCls="icon-remove" >删除</a>
                 			</shiro:hasPermission> --%>-->
                 			<shiro:hasPermission name="H010204">
                 				<a href="#" onclick="lookLink()" class="easyui-linkbutton"  iconCls="icon-search" >查看</a>
                 			</shiro:hasPermission>
                 			<shiro:hasPermission name="H010205">
                 				<a href="#" onclick="editLink()" class="easyui-linkbutton"  iconCls="icon-edit" >修改</a>
                 			</shiro:hasPermission>
                 			<shiro:hasPermission name="H010206">
                 				<a href="#" onclick="showUseTicket()" class="easyui-linkbutton"  iconCls="verify_id">优惠券</a>
                 			</shiro:hasPermission>
                     	</shiro:hasPermission>
                 	</shiro:hasPermission>
                 </center>
            </td>
         </tr>
    </table>
</div>

<!-- 添加奖券 弹出层 -->
<div id="add_lotteryTicket_dialog" class="easyui-dialog" style="width:1000px;height:550px;padding:10px 20px" closed="true"
     buttons="#dlg-buttons"data-options="modal:true">
    <br/>
        <form id="add_lotteryTicket_form" enctype="multipart/form-data" method="post">
		<table class="formTable" id="add_activity_Tab">
	         <tr>
	             <td align="right" class="label"> 标题：</td>
	             <td class="value">
	                <input name="title" id="title" data-options="required:true" class="easyui-validatebox" value="${lotteryTicketInfoVo.title }"/>
	             </td>
	         </tr>
	         <tr>
	             <td align="right" class="label"> 互动类型：</td>
	             <td class="value">
	             	<select name="interactiveType" class="easyui-combobox" style="width: 180px;"  
                  			data-options="panelHeight:'auto',editable : false" required="true">
	                   <option value="1">默认</option>
	                   <!-- <option value="2">限人数</option>
	                   <option value="3">抽奖</option>
	                   <option value="4">分级奖励</option> -->
	                </select>
	             </td>
	         </tr>
	         <tr>
	             <td align="right" class="label"> 发放方式：</td>
	             <td class="value">
	             	<select name="grantMode" class="easyui-combobox" style="width: 180px;"  
                  			data-options="panelHeight:'auto',editable : false" required="true">
	                   <option value="1">站内发放</option>
	                   <!-- <option value="2">点击领取</option>
	                    <option value="3">线下发放</option>
	                   <option value="4">站外发放</option> -->
	                </select>
	             </td>
	         </tr>
	         <tr>
	             <td align="right" class="label"> 生成奖券类型：</td>
	             <td class="value">
	             	<select id="lotteryType" name="type" class="easyui-combobox" style="width: 180px;"  
                  			data-options="panelHeight:'auto',editable : false" required="true">
	                   <option value="2">红包</option>
	                   <option value="3">加息券</option>
	                   <option value="1">实物券</option>
	                   <option value="4">体验券</option>
	                   <option value="5">费用抵用券</option>
	                   <option value="6">三方红包</option>
	                   <option value="7">现金红包</option>
	                   <option value="13">免息券</option>

	                   <!-- <option value="9">票券</option>
	                   <option value="10">虚拟现金红包</option>
	                   <option value="11">返点现金红包</option> -->
	                    <option value="12">积分券</option> 
	                </select>
	             </td>
	         </tr>
	        
	         
	          <tr id="freetickettype_">
	             <td align="right" class="label">免息券类型：</td>
	             <td class="value">
	             	<select  name="freeTicketType" id="freeTicketType" class="easyui-combobox" style="width: 180px;"  
                  			data-options="panelHeight:'auto',editable : false">
	                   <!-- <option value="0">全免</option> -->
	                   <option value="1">部分减免</option>
	                </select>
	             </td>
	         </tr>
	          <tr id="freeticketvalue_">
	             <td align="right" class="label">减免利率：</td>
	             <td class="value">
	             	<input  name="freeTicketValue" id="freeTicketValue" class="easyui-numberbox"  onblur="validVal()" style="width: 240px" data-options="min:0.1,max:100,precision:2"
	             	value=""/>%
	             </td>
	         </tr>
	         <tr id="cashPackage_">
	             <td align="right" class="label">红包类型：</td>
	             <td class="value">
	             	<select id="cashPackageType" name="cashPackageType" class="easyui-combobox" style="width: 180px;"  
                  			data-options="panelHeight:'auto',editable : false">
	                   <option value="0">按固定额度</option>
	                   <option value="1">按投资金额</option>
	                   <option value="2">按期限</option>
	                   <option value="3">按预期年化</option>
	                   <option value="4">按返现比例</option>
	                </select>
	             </td>
	         </tr>
	         <tr id="cashPackageAmount_">
	             <td align="right" class="label">固定金额(元)：</td>
	             <td class="value">
	             	<input name="cashPackageAmount" class="easyui-numberbox" style="width: 240px" data-options="min:0.01,max:10000000,precision:2"
	             	value=""/>
	             </td>
	         </tr>
	         <tr id="investBackRate_">
	             <td align="right"  class="label">返现率：</td>
	             <td class="value">
	             	<input name="investBackRate" class="easyui-numberbox" style="width: 240px" data-options="min:0.01,max:100,precision:2"
	             	value=""/>%
	             </td>
	         </tr>
	         <tr id="addInterestRate_">
	             <td align="right"  class="label">加息率：</td>
	             <td class="value">
	             	<input name="addInterestRate" id="addInterestRate" class="easyui-numberbox" style="width: 240px" data-options="min:0.01,max:20,precision:2"
	             	value=""/>%
	             </td>
	         </tr>
	         <tr id="addInterestType_">
	         	<td align="right" class="label">加息类型</td>
	         	<td class="value">
	         		<select id="addInterestType" name="addInterestType" class="easyui-combobox" style="width: 180px;">
	                   <option value="1">自定义加息时长</option>
	                   <option value="2">按投资产品期限</option>
                  	</select>
	         	</td>
	         </tr>
	         <tr id="addInterestDays_">
	             <td align="right"  class="label" id = "addDaysTd">加息时长：</td>
	             <td class="value">
	             	<input name="addInterestDays" id="addInterestDays" class="easyui-numberbox" style="width: 240px" data-options="required:true,min:1,max:100000,precision:0"
	             	value=""/>天
	             </td>
	         </tr>
	         <tr id="maxInvestAmount_">
	             <td align="right"  class="label">最大投资金额：</td>
	             <td class="value">
	             	<input name="maxInvestAmount" id="maxInvestAmount" class="easyui-numberbox" style="width: 240px" data-options="min:0.01,max:10000000,precision:2"
	             	value=""/>元
	             </td>
	         </tr>
	         
	         <tr id="tasteType_">
	             <td align="right" class="label">体验金类型：</td>
	             <td class="value">
	             	<select id="tasteType" name="tasteType" class="easyui-combobox" style="width: 180px;"  
                  			data-options="panelHeight:'auto',editable : false">
	                   <option value="0">按固定额度</option>
	                   <option value="1">按投资金额</option>
	                </select>
	                
	                <input name="investRatio"  id="investRatio" class="easyui-numberbox" style="width: 70px" data-options="min:1,max:100,precision:0,value:1"
	             	value="1" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/><font id="ratioFont">倍</font>
	             </td>
	         </tr>
	         <tr id="maxTasteAmount_">
	             <td align="right"  class="label" >赠送金额上限：</td>
	             <td class="value">
	             	<input name="maxTasteAmount" id="maxTasteAmount" class="easyui-numberbox" style="width: 240px" data-options="min:0.01,max:1000000000,precision:2"
	             	value=""/>元
	             </td>
	         </tr>
	         <tr id="amount_">
	             <td align="right"  class="label">奖券金额(元)：</td>
	             <td class="value">
	             	<input name="amount" id="amount" class="easyui-numberbox" style="width: 240px" data-options="min:0.01,max:10000000,precision:2"
	             	value=""/>
	             </td>
	         </tr>
	         <tr id="tasteRateDays_">
	             <td align="right"  class="label">生息天数(天)：</td>
	             <td class="value">
	             	<input name="tasteRateDays" id="tasteRateDays" class="easyui-numberbox" style="width: 240px" data-options="min:1,max:999,precision:0"
	             	value=""/>
	             </td>
	         </tr>
	         <tr id="borrowTypes_">
       		  	<td align="right"  class="label">适用标：</td>
       			<td class="value" colspan="3">
       				<input id="borrowTypes" type="hidden" name="borrowTypes"/>
       				<input id="borrowTypes1" value="3" type="checkbox" class="easyui-validatebox"/>新手标
       				<input id="borrowTypes2" value="1" type="checkbox" class="easyui-validatebox"/><e id="huo">活期宝</e>
       				<input id="borrowTypes3" value="2" type="checkbox" class="easyui-validatebox"/>优选计划
       				<input id="borrowTypes4" value="0" type="checkbox" class="easyui-validatebox"/>散标
       				<input id="borrowTypes5" value="5" type="checkbox" class="easyui-validatebox"/>游艇宝
       				<input id="borrowTypes6" value="6" type="checkbox" class="easyui-validatebox"/>酒店宝
       				<input id="borrowTypes8" value="8" type="checkbox" class="easyui-validatebox"/>秒借
       				<input id="borrowTypes9" value="9" type="checkbox" class="easyui-validatebox"/>有用分期
       				<input id="borrowTypes10" value="10" type="checkbox" class="easyui-validatebox"/>车信宝
       			</td>
       		</tr>
       		<tr id="repaymentType_">
       		  	<td align="right"  class="label">可使用还款类型：</td>
       			<td class="value" colspan="3">
       				<input id="repaymentTypes" type="hidden" name="repaymentTypes"/>
       				<input id="repaymentType1" value="3" type="checkbox" class="easyui-validatebox"/>提前还款
       				<input id="repaymentType2" value="1" type="checkbox" class="easyui-validatebox"/>正常还款
       				<input id="repaymentType3" value="4" type="checkbox" class="easyui-validatebox"/>逾期还款
       			</td>
       		</tr>
       		<tr id="borrowLoanPeriods_" style="display:none">
       			<td align="right"  class="label">标的借款期限(月)：</td>
       			<td class="value" coslpan="3">
       				<input id="borrowLoanPeriods" type="hidden" name="borrowLoanPeriods"/>
       				<input id="periods1" value="3" type="checkbox" class="easyui-validatebox" />3月
       				<input id="periods2" value="6" type="checkbox" class="easyui-validatebox" />6月
       				<input id="periods3" value="12" type="checkbox" class="easyui-validatebox" />12月
       				<input id="periods4" value="24" type="checkbox" class="easyui-validatebox" />24月
       			</td>
       		</tr>
       		<tr id="publishPlatforms_">
       		  	<td align="right"  class="label">使用平台：</td>
       			<td class="value" colspan="3">
       				<input id="publishPlatforms" type="hidden" name="publishPlatforms"/>
       				<input id="publishPlatforms1" value="1" type="checkbox" class="easyui-validatebox" />PC
       				<input id="publishPlatforms2" value="2" type="checkbox" class="easyui-validatebox" />APP
       				<input id="publishPlatforms3" value="3" type="checkbox" class="easyui-validatebox" />触屏版
       			</td>
       		</tr>
	         <tr id="validTermTypeId_">
	             <td align="right" class="label"> 有效期类型：</td>
	             <td class="value">
	             	<select name="validTermType" id="validTermTypeId" class="easyui-combobox"
	             	data-options="panelHeight:'auto',editable : false" >
	             	   <option value="2">指定有效天数</option>
	                   <option value="1">指定时间范围</option>
	                </select>
	             </td>
	         </tr>
	         <tr id="validTermId">
	             <td align="right"  class="label">奖券有效期(天)：</td>
	             <td class="value">
	             	<input name="validTerm" id="validTerm"  class="easyui-validatebox" style="width: 240px" value="" data-options="validType:'daysValid'"/>
	             </td>
	         </tr>
	         <tr id="validDayStartId">
	             <td align="right"  class="label">有效开始时间：</td>
	             <td class="value">
	             	<input name="validDayStart" id="validDayStart" class="easyui-datetimebox" editable="false" style="width: 180px" value=""/>
	             </td>
	         </tr>
	         <tr id="validDayEndId">
	             <td align="right"  class="label">有效截止时间：</td>
	             <td class="value">
	             	<input name="validDayEnd"  id="validDayEnd" class="easyui-datetimebox" editable="false" style="width: 180px" value="" validType="dataEqualTo['#validDayStart']"/>
	             </td>
	         </tr>
	         <tr id="investMiniAmount_">
	             <td align="right"  class="label">投资使用门槛(元)：</td>
	             <td class="value">
	             	<input name="investMiniAmount" id="investMiniAmount" class="easyui-validatebox" style="width: 240px" data-options="validType:'moneyValid'" value=""/>
	             </td>
	         </tr>
	         <tr id="generateNum_">
	             <td align="right"  class="label">生成优惠券张数：</td>
	             <td class="value">
	             	<input name="generateNum" id="generateNum"  class="easyui-validatebox" style="width: 240px" data-options="validType:'isNumberValid'"
	             	value="" />
	             </td>
	         </tr>
	         <tr id="limitApieceNum_">
	             <td align="right"  class="label">限制每人领取张数：</td>
	             <td class="value">
	             	<input name="limitApieceNum" id="limitApieceNum" class="easyui-validatebox" style="width: 240px" data-options="validType:'isNumberValid'"
	             	value=""/>
	             </td>
	         </tr>
	         <tr id="integralType_">
	         	<td align="right" class="label">额度类型</td>
	         	<td class="value">
	         		<select id="integralType" name="integralType" class="easyui-combobx" style="width: 180px;"
	         			data-options="panelHeight:'auto',editable : false">
	         			<option value="1">按固定数值赠送</option>
	                    <option value="2">按公式计算赠送</option>
	                    <option value="3">无规律类型</option>		
	         		</select>
	         	</td>
	         </tr>
	         <tr id="integralPoints_">
	             <td align="right" class="label">固定积分：</td>
	             <td class="value">
	             	<input name="integralPoints" class="easyui-numberbox" style="width: 240px" data-options="min:1,max:100000,precision:2"
	             	value=""/>
	             </td>
	         </tr>
	         <tr id="integraFormula">
	         	<td align="right" class="label">积分公式</td>
	         	<td class="value">投资金额/借款金额*<input id="integralRatio" name="integralRatio" type="text" class="easyui-numberbox" style="width: 100px" data-options="min:0.01,max:10000,precision:2"
	             	value=""/>/<input id="integralParamOne" name="integralParamOne"  class="easyui-numberbox" style="width: 100px" data-options="min:0.01,max:10000,precision:2"
	             	value=""/>*<input id="integralParamTwo" name="integralParamTwo"  class="easyui-numberbox" style="width: 100px" data-options="min:0.01,max:10000,precision:2"
	             	value=""/>
	         	</td>
	         </tr>
	         <tr>
	             <td align="right" class="label">开始时间：</td>
	             <td class="value">
	             	<input id="startTime" name="startTime" editable="false" class="easyui-datetimebox" style="width: 180px" data-options="required:true" 
	             	value="<fmt:formatDate value='${lotteryTicketInfoVo.registerEnd }' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
	             </td>
	         </tr>
	         <tr>
	             <td align="right" class="label">结束时间：</td>
	             <td class="value">
	             	<input name="endTime" editable="false" class="easyui-datetimebox" style="width: 180px" data-options="required:true" validType="dataEqualTo['#startTime']"
	             	value="<fmt:formatDate value='${lotteryTicketInfoVo.registerEnd }' pattern='yyyy-MM-dd HH:mm:ss'/>"/>
	             </td>
	         </tr>
	         <tr>
             <td align="right" class="label"> 状态：</td>
             <td class="value">
             	<select name="status" id="status" class="easyui-combobox" style="width: 180px;"  
                  			data-options="panelHeight:'auto',editable : false" required="true">
                   <option value="1">生效</option>
                   <option value="2">失效</option>
                </select>
             </td>
         </tr>
	         <tr>
	             <td align="center" colspan="4">
	             	<a href="#" id="add_lotteryTicket_submit"  class="easyui-linkbutton" iconcls="icon-ok">确 定</a> 
	             	&nbsp;&nbsp;
	 				<a href="#" id="add_lotteryTicket_cancel"  class="easyui-linkbutton" iconcls="icon-cancel">取 消</a>
	             </td>
	         </tr>
	   </table> 
	 </form>
</div>
<div id="lotteryTicket_dialog"></div>
<div id="ticket_use_detail_dialog">
<div id="integral_detail_dialog">
<input type="hidden" id="tempLtId">
</div>

<script>
    $(function () {
        // 初始化数据表格
        renderLotteryTicketDataGrid();
        // 搜索按钮监听
        $("#searchLink").click(doSearch);

        // 添加奖券 按钮监听
        $("#add_lotteryTicket").click(addLotteryTicket);
        // 添加奖券-确定 按钮监听
        $("#add_lotteryTicket_submit").click(addLotteryTicketSubmit);
        // 添加奖券-取消 按钮监听
        $("#add_lotteryTicket_cancel").click(addLotteryTicketCancel);
        //查看想请按钮
        //$("#lotteryTicketdetail").click(lotteryTicketdetail);
        $('#validTermTypeId').combobox({
            onSelect:function(record){
            	var termVal = $('#validTermTypeId').combobox('getValue');
            	if(termVal == 1){
            		$("#validDayStartId").show();
            		$("#validDayEndId").show();
            		$("#validTermId").hide();
            		$("#validTermId").find("[name='validTerm']").val("");
            	}else{
            		$("#validDayStartId").find("input[type=text]").val("");
            		$("#validDayEndId").find("input[type=text]").val("");
            		$("#validTermId").show();
            		$("#validDayStartId").hide();
            		$("#validDayEndId").hide();
            	}
            }
    	});
        
        $("#lotteryType").combobox({
			onSelect:function(newValue,oldValue){
				var termVal = $('#lotteryType').combobox('getValue');
				$("#addDaysTd").html("加息时长：");
				//实物券
				if(termVal==1){
					resetCheckbox();
					freeTicketInvest();
					$("#addInterestRate_").hide();
					$("#addInterestType_").hide();
			    	$("#addInterestDays_").hide();
			    	$("#maxInvestAmount_").hide();
			    	$("#tasteRateDays_").hide();
			    	$("#maxTasteAmount_").hide();
			    	$("#tasteType_").hide();
			    	$("#cashPackage_").hide();
			    	$("#publishPlatforms_").show();
			    	$("#validTermTypeId_").show();
			    	$("#generateNum_").show();
			    	$("#limitApieceNum_").show();
			    	$("#amount_").show();
			    	$("#investMiniAmount_").show();
			    	$("#investMiniAmount").numberbox({ required: true });
			    	$("#borrowTypes_").show();
			    	$("#huo").hide();
					$("#borrowTypes2").hide();
					$("#cashPackageAmount_").hide();
					$("#investBackRate_").hide();
					$("#ticketAllAmount_").hide();
					$("#addInterestType").combobox({ required:false});
					$("#addInterestDays").numberbox({ required: false });
					$("#integralType_").hide();
					$("#integralPoints_").hide();					
					$("#freetickettype_").hide();
					$("#freeticketvalue_").hide();
					$("#repaymentType_").hide();
				//现金券
				}else if(termVal==2){
					resetCheckbox();
					freeTicketInvest();
					$("#addInterestRate_").hide();
					$("#addInterestType_").hide();
			    	$("#addInterestDays_").hide();
			    	$("#maxInvestAmount_").hide();
			    	$("#tasteRateDays_").hide();
			    	$("#maxTasteAmount_").hide();
			    	$("#tasteType_").hide();
			    	$("#cashPackage_").hide();
			    	$("#publishPlatforms_").show();
			    	$("#validTermTypeId_").show();
			    	$("#generateNum_").show();
			    	$("#limitApieceNum_").show();
			    	$("#amount_").show();
			    	$("#investMiniAmount_").show();
			    	$("#investMiniAmount").numberbox({ required: true });
			    	$("#borrowTypes_").show();
			    	$("#huo").hide();
					$("#borrowTypes2").hide();
					$("#cashPackageAmount_").hide();
					$("#investBackRate_").hide();
					$("#ticketAllAmount_").hide();
					$("#addInterestType").combobox({ required:false});
					$("#addInterestDays").numberbox({ required: false });
					$("#integralType_").hide();
					$("#integralPoints_").hide();	
					$("#freetickettype_").hide();
					$("#freeticketvalue_").hide();
					$("#repaymentType_").hide();
				//加息券
				}else if(termVal==3){
					resetCheckbox();
					freeTicketInvest();
					$("#addInterestRate_").show();
					$("#addInterestType_").show();
			    	$("#addInterestDays_").show();
			    	$("#maxInvestAmount_").show();
			    	$("#amount_").hide();
			    	$("#investMiniAmount_").show();
			    	$("#investMiniAmount").numberbox({ required: true });
			    	$("#tasteType_").hide();
			    	$("#cashPackage_").hide();
			    	$("#tasteRateDays_").hide();
			    	$("#maxTasteAmount_").hide();
			    	$("#borrowTypes_").show();
			    	$("#huo").show();
			    	$("#borrowTypes2").show();
			    	$("#borrowTypes_").show();
			    	$("#publishPlatforms_").show();
			    	$("#validTermTypeId_").show();
			    	$("#generateNum_").show();
			    	$("#limitApieceNum_").show();
			    	$("#cashPackageAmount_").hide();
			    	$("#investBackRate_").hide();
			    	$("#ticketAllAmount_").hide();
			    	$("#borrowTypes2").attr("disabled",false);
			    	$("#addInterestType").combobox({ required:true});
			    	$("#addInterestDays").numberbox({ required: false });
			    	$('#addInterestType').combobox('setValues','');
			    	$("#integralType_").hide();
			    	$("#integralPoints_").hide();			    	
			    	$("#freetickettype_").hide();
					$("#freeticketvalue_").hide();
					$("#repaymentType_").hide();
			    //体验金
			    }else if(termVal==4){
			    	resetCheckbox();
			    	freeTicketInvest();
			    	$("#amount_").show();
			    	$("#publishPlatforms_").show();
			    	$("#validTermTypeId_").show();
			    	$("#generateNum_").show();
			    	$("#limitApieceNum_").show();
			    	$("#tasteType_").show();
			    	$("#investRatio").hide();
			    	$("#ratioFont").hide();
			    	$("#tasteRateDays_").show();
			    	$("#cashPackage_").hide();
			    	$("#borrowTypes_").hide();
			    	$("#huo").hide();
			    	$("#investMiniAmount_").hide();
			    	$("#investMiniAmount").numberbox({ required: false });
			    	$("#cashPackageAmount_").hide();
					$("#investBackRate_").hide();
					$("#ticketAllAmount_").hide();
					$("#addInterestRate_").hide();
					$("#addInterestType_").hide();
			    	$("#addInterestDays_").hide();
			    	$("#maxInvestAmount_").hide();
			    	$("#addInterestType").combobox({ required:false});
			    	$("#addInterestDays").numberbox({ required: false });
			    	$("#integralType_").hide();
			    	$("#integralPoints_").hide();	
			    	$("#freetickettype_").hide();
					$("#freeticketvalue_").hide();
					$("#repaymentType_").hide();
			    //现金红包
				}else if(termVal==7){
					resetCheckbox();
					freeTicketInvest();
					$("#cashPackage_").show();
					$("#ticketAllAmount_").show();
					$("#limitApieceNum_").show();
					$("#generateNum_").show();
			    	$("#investMiniAmount_").hide();
			    	$("#investMiniAmount").numberbox({ required: false });
			    	$("#validDayEndId").hide();
			    	$("#validDayStartId").hide();
			    	$("#validTermId").hide();
			    	$("#validTermTypeId_").hide();
			    	$("#publishPlatforms_").hide();
			    	$("#borrowTypes_").hide();
			    	$("#tasteRateDays_").hide();
			    	$("#amount_").hide();
			    	$("#maxTasteAmount_").hide();
			    	$("#tasteType_").hide();
			    	$("#maxInvestAmount_").hide();
			    	$("#addInterestDays_").hide();
			    	$("#addInterestRate_").hide();
			    	$("#addInterestType_").hide();
			    	$("#huo").hide();
			    	$("#addInterestType").combobox({ required:false});
			    	$("#addInterestDays").numberbox({ required: false });
			    	$("#integralType_").hide();
			    	$("#integralPoints_").hide(); 	
			    	$("#freetickettype_").hide();
					$("#freeticketvalue_").hide();
					$("#repaymentType_").hide();
			    //虚拟现金红包
				}else if(termVal==10){
					resetCheckbox();
					freeTicketInvest();
					$("#cashPackage_").hide();
					$("#ticketAllAmount_").show();
					$("#cashPackageAmount_").show();
					$("#investBackRate_").hide();
					$("#limitApieceNum_").hide();
					$("#generateNum_").hide();
			    	$("#investMiniAmount_").hide();
			    	$("#investMiniAmount").numberbox({ required: false });
			    	$("#validDayEndId").hide();
			    	$("#validDayStartId").hide();
			    	$("#validTermId").hide();
			    	$("#validTermTypeId_").hide();
			    	$("#publishPlatforms_").hide();
			    	$("#borrowTypes_").hide();
			    	$("#tasteRateDays_").hide();
			    	$("#amount_").hide();
			    	$("#maxTasteAmount_").hide();
			    	$("#tasteType_").hide();
			    	$("#maxInvestAmount_").hide();
			    	$("#addInterestDays_").hide();
			    	$("#addInterestRate_").hide();
			    	$("#addInterestType_").hide();
			    	$("#huo").hide();
			    	$("#addInterestType").combobox({ required:false});
			    	$("#addInterestDays").numberbox({ required: false });
			    	$("#integralType_").hide();
			    	$("#integralPoints_").hide();    	
			    	$("#freetickettype_").hide();
					$("#freeticketvalue_").hide();
					$("#repaymentType_").hide();
			    //按投资金额 ：比例返现红包
				}else if(termVal==11){
					resetCheckbox();
					freeTicketInvest();
					$("#cashPackage_").hide();
					$("#ticketAllAmount_").show();
					$("#cashPackageAmount_").hide();
			    	$("#maxTasteAmount_").show();
					$("#investBackRate_").show();
					$("#limitApieceNum_").hide();
					$("#generateNum_").hide();
			    	$("#investMiniAmount_").hide();
			    	$("#investMiniAmount").numberbox({ required: false });
			    	$("#validDayEndId").hide();
			    	$("#validDayStartId").hide();
			    	$("#validTermId").hide();
			    	$("#validTermTypeId_").hide();
			    	$("#publishPlatforms_").hide();
			    	$("#borrowTypes_").hide();
			    	$("#tasteRateDays_").hide();
			    	$("#amount_").hide();
			    	$("#tasteType_").hide();
			    	$("#maxInvestAmount_").hide();
			    	$("#addInterestDays_").hide();
			    	$("#addInterestRate_").hide();
			    	$("#addInterestType_").hide();
			    	$("#huo").hide();
			    	$("#addInterestType").combobox({ required:false});
			    	$("#addInterestDays").numberbox({ required: false });
			    	$("#integralType_").hide();
			    	$("#integralPoints_").hide();
			    	$("#freetickettype_").hide();
					$("#freeticketvalue_").hide();
					$("#repaymentType_").hide();
				}else if(termVal==12){
					$("#cashPackage_").hide();
					$("#ticketAllAmount_").show();
					$("#limitApieceNum_").hide();
					$("#generateNum_").hide();
			    	$("#investMiniAmount_").hide();
			    	$("#investMiniAmount").numberbox({ required: false });
			    	$("#validDayEndId").hide();
			    	$("#validDayStartId").hide();
			    	$("#validTermId").hide();
			    	$("#validTermTypeId_").hide();
			    	$("#publishPlatforms_").hide();
			    	$("#borrowTypes_").hide();
			    	$("#tasteRateDays_").hide();
			    	$("#amount_").hide();
			    	$("#maxTasteAmount_").hide();
			    	$("#tasteType_").hide();
			    	$("#maxInvestAmount_").hide();
			    	$("#addInterestDays_").hide();
			    	$("#addInterestRate_").hide();
			    	$("#addInterestType_").hide();
			    	$("#huo").hide();
			    	$("#addInterestType").combobox({ required:false});
			    	$("#addInterestDays").numberbox({ required: false });
			    	$("#integralType_").show();
			    	$("#integralPoints_").show();
			    	$("#borrowLoanPeriods_").hide();
			    	$("#freetickettype_").hide();
					$("#freeticketvalue_").hide();
					$("#repaymentType_").hide();
				} else if(termVal==13){
					resetCheckbox();
					freeTicketInvest();
					$("#freetickettype_").show();
					$("#freeticketvalue_").show();
					$("#repaymentType_").show();
					$("#borrowTypes_").show();
					$("#validTermTypeId_").show();
					$("#generateNum_").show();
					$("#limitApieceNum_").show();
				 	
					$("#freeTicketType").combobox({ required: true });
					$("#freeTicketValue").numberbox({ required: true });
					$('#freeTicketType').combobox('setValues','');
					$("#freeTicketType").val("");
					 
					
					$("#cashPackage_").hide();
					$("#cashPackageAmount_").hide();
					$("#investBackRate_").hide();
					$("#addInterestRate_").hide();
					$("#addInterestType_").hide();
					$("#addInterestDays_").hide();
					$("#maxInvestAmount_").hide();
					$("#tasteType_").hide();
					$("#maxTasteAmount_").hide();
					$("#amount_").hide();
					$("#tasteRateDays_").hide();
					$("#borrowLoanPeriods_").hide();
					$("#publishPlatforms_").hide();
					$("#investMiniAmount_").hide(); 
					$("#freeticketvalue_").hide();
					//设置标的类型 
				}else{
					resetCheckbox();
					freeTicketInvest();
					$("#addInterestRate_").hide();
					$("#addInterestType_").hide();
			    	$("#addInterestDays_").hide();
			    	$("#maxInvestAmount_").hide();
			    	$("#tasteRateDays_").hide();
			    	$("#maxTasteAmount_").hide();
			    	$("#tasteType_").hide();
			    	$("#cashPackage_").hide();
			    	$("#publishPlatforms_").show();
			    	$("#validTermTypeId_").show();
			    	$("#generateNum_").show();
			    	$("#limitApieceNum_").show();
			    	$("#amount_").show();
			    	$("#investMiniAmount").numberbox({ required: true });
			    	$("#investMiniAmount_").show();
			    	$("#borrowTypes_").show();
			    	$("#huo").hide();
					$("#borrowTypes2").hide();
					$("#cashPackageAmount_").hide();
					$("#investBackRate_").hide();
					$("#ticketAllAmount_").hide();
					$("#addInterestType").combobox({ required:false});
					$("#addInterestDays").numberbox({ required: false });
					$("#integralType_").hide();
					$("#integralPoints_").hide();					
					$("#freetickettype_").hide();
					$("#freeticketvalue_").hide();
					$("#repaymentType_").hide();
				}
			}
		});
        //设置免息默认值
        $("#freeTicketType").combobox({
			onSelect:function(newValue,oldValue){
				var tasteTypeVal = $('#freeTicketType').combobox('getValue');
				if(tasteTypeVal==0){
					$("#freeticketvalue_").hide();
					$('#freeTicketValue').numberbox('setValue','100');
			    }else{
			    	$('#freeTicketValue').numberbox('setValue','');
			    	$("#freeticketvalue_").show();
				}
			}
		});
		//体验金类型
        $("#tasteType").combobox({
			onSelect:function(newValue,oldValue){
				var tasteTypeVal = $('#tasteType').combobox('getValue');
				if(tasteTypeVal==0){
					$("#amount_").show();
					$("#maxTasteAmount_").hide();
					$("#investRatio").hide();
					$("#ratioFont").hide();
					$("#investRatio").val(1);
			    }else{
			    	$("#amount_").hide();
					$("#maxTasteAmount_").show();
					$("#investRatio").show();
					$("#ratioFont").show();
					$("#investRatio").val(1);
				}
			}
		});
        //现金红包类型
        $("#cashPackageType").combobox({
			onSelect:function(newValue,oldValue){
				var tasteTypeVal = $('#cashPackageType').combobox('getValue');
				if(tasteTypeVal==0){
					$("#cashPackageAmount_").show();
					$("#investBackRate_").hide();
					$("#investBackRate").val("");
					$("#addInterestDays_").hide();
					$("#addInterestDays").val("");
					$('#addInterestDays').numberbox({required:false });
			    }else if(tasteTypeVal==1){
					$("#investBackRate_").show();
			    	$("#cashPackageAmount_").hide();
					$("#addInterestDays_").hide();
					$('#addInterestDays').numberbox({required:false });
				}else if(tasteTypeVal==2){
					$("#cashPackageAmount_").hide();
					$("#investBackRate_").show();
					$("#addInterestDays_").show();
					$("#addDaysTd").html("返现时长：");
					$('#addInterestDays').numberbox({required:true });
			    }else if(tasteTypeVal==3){
					$("#cashPackageAmount_").hide();
					$("#investBackRate_").hide();
					$("#addInterestDays_").show();
					$("#addDaysTd").html("奖励天数：");
					$('#addInterestDays').numberbox({required:true });
			    }else if(tasteTypeVal==4){
					$("#cashPackageAmount_").hide();
					$("#investBackRate_").show();
					$("#addDaysTd").html("奖励天数：");
					$("#addInterestDays_").hide();
					$('#addInterestDays').numberbox({required:false });
			    }
			}
		});
        //积分类型
        $("#integralType").combobox({
			onSelect:function(newValue,oldValue){
				var integralTypeVal = $('#integralType').combobox('getValue');
				if(integralTypeVal==1){
					$("#integralPoints_").show();
					$("#integraFormula").hide();
			    }else if(integralTypeVal==2){
			    	$("#integralPoints_").hide();
			    	$("#integraFormula").show();
				}else{
					$("#integralPoints_").hide();
					$("#integraFormula").hide();
				}
			}
		});
        
      //加息类型
        $("#addInterestType").combobox({
			onSelect:function(newValue,oldValue){
				var addInterestType = $('#addInterestType').combobox('getValue');
				if(addInterestType==2){
					$("#addInterestDays_").hide();
					$("#borrowTypes2").attr("checked",false);
					$("#borrowTypes2").attr("disabled",true);
					$("#addInterestDays").numberbox({ required: false });
			    }else{
			    	$("#addInterestDays_").show();
			    	$("#borrowTypes2").attr("disabled",false);
			    	$("#addInterestDays").numberbox({ required: true });
				}
			}
		});
        
        if ($.browser.msie) { 
        	$('input:checkbox').click(function () { 
        		this.blur(); 
        		this.focus(); 
        	}); 
        }; 
        
        $("#borrowTypes3").change(function() { 
        	borrowLoanPeriodsInit();
        }); 
        
        $("#periods1").change(function() { 
        	borrowLoanPeriodsChangeCheck();
        }); 
        
        $("#periods2").change(function() { 
        	borrowLoanPeriodsChangeCheck();
        });
        
        $("#periods3").change(function() { 
        	borrowLoanPeriodsChangeCheck();
        });
        
        $("#periods4").change(function() { 
        	borrowLoanPeriodsChangeCheck();
        });
    });
    /*
     * 点击查询按钮触发
     */
    function doSearch() {
        $('#lotteryTicketDataGrid').datagrid('reload',{
        	id: $('#id').val(),
        	title: $('#ltTitle').val(),
        	type: $('#ltType').combobox("getValue"),
        	status: $('#ltStatus').combobox("getValue"),
        	startTime: $('#createStartTime').datebox("getValue"),
        	endTime: $('#createEndTime').datebox("getValue")
        });
    }
    /**
     * 添加奖券 按钮监听
     */
    function addLotteryTicket() {
    	$("#cashPackage_").hide();
    	$("#tasteType_").hide();
        $("#maxTasteAmount_").hide();
    	$("#addInterestRate_").hide();
    	$("#addInterestType_").hide();
    	$("#addInterestDays_").hide();
    	$("#tasteRateDays_").hide();
    	$("#maxInvestAmount_").hide();
    	$("#cashPackageAmount_").hide();
		$("#investBackRate_").hide();
		$("#ticketAllAmount_").hide();
		$("#integralType_").hide();
		$("#integraFormula").hide();
		$("#integralPoints_").hide();
		$("#freetickettype_").hide();
		$("#freeticketvalue_").hide();
		$("#repaymentType_").hide();
        // 弹出
        $('#add_lotteryTicket_dialog').dialog('open').dialog("setTitle", "添加奖券");
        $('#add_lotteryTicket_form').find("input").each(function(){
        	$(this).val("");
        });
        $("#integralParamOne").numberbox('setValue',1);
    	$("#integralRatio").numberbox('setValue',1);
    	$("#integralParamTwo").numberbox('setValue',1);
    }

    /**
     * 点击 添加奖券-确定 按钮
     */
 
    function addLotteryTicketSubmit(){
    	publishPlatformsClick();
    	borrowTypesClick();
    	repaymentTypesClick();
    	if($("#borrowTypes3").attr("checked")){
    		borrowLoanPeriodsClick();
    	}
    	
    	var repayType = $("#repaymentTypes").val(); 
    	var validTermTypeId = $('#validTermTypeId').combobox('getValue'); 
    	var termVal = $('#lotteryType').combobox('getValue');
    	var generateNum = $('#generateNum').val(); 
    	var limitApieceNum = $('#limitApieceNum').val(); 
    	if(termVal == 13 && repayType == ""){
    		$.messager.alert('错误',"请选择还款类型");
    		return;
    	}
    	if(termVal == 13 && validTermTypeId == ""){
    		$.messager.alert('错误',"请选择有效期类型");
    		return;
    	}else if(termVal == 13 && validTermTypeId == 2){
    		if($("#validTerm").val() == ""){
    			$.messager.alert('错误',"请填写奖券有效期");
        		return;
    		}
    	}else if(termVal == 13 && validTermTypeId == 1){
    		var validDayStart = $('#validDayStart').datebox("getValue");
    		var validDayEnd = $('#validDayEnd').datebox("getValue");
    		if(validDayStart == "" || validDayEnd){
    			$.messager.alert('错误',"请填写奖券有效期");
        		return;
    		}
    	}
    	if(termVal == 13 && generateNum == ""){
    		$.messager.alert('错误',"请填写生成优惠券张数");
    		return;
    	}
    	if(termVal == 13 && limitApieceNum == ""){
    		$.messager.alert('错误',"限制每人领取张数");
    		return;
    	}
		//alert(termVal+"-"+generateNum+"-"+limitApieceNum);
    	if($('#lotteryType').combobox('getValue')==3&&$("#maxInvestAmount").val()==""){
    		$.messager.confirm('提示框', '最大投资金额无上限,是否保存？',function(y){
    			if(y){
	    			submit();
    			}
    		})
    	}else{
    		submit();
    	}
    } 
    function submit(){
		var title= $('#title').val();
        if(title.length>20){
        	$.messager.alert('错误','标题长度不能超过20');
        	return;
        }
    	$.messager.progress({text:'执行中...'});
        $('#add_lotteryTicket_form').form('submit',{
            url: '/lotteryTicket/insertLotteryTicket',
            onSubmit: function(){
            	var validate = $(this).form('validate');
            	if(!validate){
            		$.messager.progress('close');
            	}
                return validate;
            },
            success: function(result){
            	$.messager.progress('close');
            	var result = eval('(' + result + ')');
            	if (result.code==1) {
    				$('#add_lotteryTicket_dialog').dialog('close');
    				doSearch();
    				$.messager.alert('成功',"新增奖券成功");
    			} else {
    				$.messager.alert('错误',result.msg);
    			}
            }
        });
    }

    // 添加奖券 取消
    function addLotteryTicketCancel() {
        $('#add_lotteryTicket_dialog').dialog('close');
    }
    
    /**
     * 奖券详细信息
     */
    function lotteryTicketDetail(id,flag,status){
        if (id!=null&&id!=""&&flag!=null&&flag!=""){
            var url = '/lotteryTicket/lotteryTicketDetail?id='+id+'&editFlag='+flag;
            $('#lotteryTicket_dialog').html("<iframe width='1000' height='450' frameborder=0  src='"+url+"'></iframe>");
            $('#lotteryTicket_dialog').dialog({
                title:'奖券信息',
                modal: true,
                width:'auto',
                height:'auto'
            });
        }
    }
    /**
     * 显示奖券使用详细信息
     */
    function showUseTicketDetail(id,flag,status){
        if (id!=null&&id!=""){
        	$("#tempLtId").val(id);
            var url = '/lotteryTicket/goTicketUseDetailList?id='+id+'&editFlag='+flag;
            $('#ticket_use_detail_dialog').html("<iframe width='1000' height='400' frameborder=0  src='"+url+"'></iframe>");
            $('#ticket_use_detail_dialog').dialog({
                title:'奖券列表',
                modal: true,
                width:'auto',
                height:'auto'
            });
        }
    }
    //显示积分使用详细信息
    function showIntegralUseDetail(id){
    	if(id != null && id != ""){
    		var url = '/lotteryTicket/goIntegralUseDetail?id='+id;
    		$('#integral_detail_dialog').html("<iframe width='1000' height='400' frameborder=0  src='"+url+"'></iframe>");
            $('#integral_detail_dialog').dialog({
                title:'积分发放列表',
                modal: true,
                width:'auto',
                height:'auto'
            });
    	}
    }
    
    /**
     * 渲染奖券表格
     */
    function renderLotteryTicketDataGrid() {
    	$('#add_lotteryTicket_dialog').dialog('close');
        $("#lotteryTicketDataGrid").datagrid({
            url: "/lotteryTicket/queryLotteryTickets",
            loadMsg: "loading data...",
            fit:true,
            pagination: true,
            singleSelect:true,
            columns: [
                [
                    {field: 'id', title: '奖池Id号',width:50, align: 'center'},
                    {field: 'title', title: '奖池名称', fit:true, align: 'center'},
                    {field: 'type', title: '生成券类型', align: 'center',width:80,formatter:function(value,row,index){
						if(value==1){
							return "实物券";	
						}else if(value==2){
							return "红包";
						}else if(value==3){
							return "加息券";
						}else if(value==4){
							return "体验券";
						}else if(value==5){
							return "费用抵用券";
						}else if(value==6){
							return "三方红包";
						}else if(value==7){
							return "现金";
						}else if(value==8){
							return "直抵券";}
						else if(value==9){
							return "票券";}
						else if(value==10){
							return "虚拟现金红包";}
						else if(value==11){
							return "返点现金红包";}
						else if(value==12){
							return "积分券";}
						else if(value==13){
							return "免息券";}
                      }
                    },
                    {field: 'borrowTypes', title: '适用标', align: 'center',width:160},
                    {field: 'publishPlatforms', title: '使用平台', align: 'center',width:160},
                    {field: 'startTime', title: '开始时间', fit:true, align: 'center'},
                    {field: 'endTime', title: '结束时间', fit:true, align: 'center'},
                    {field: 'createTime', title: '创建时间', fit:true, gn: 'center'},
                    {field: 'status', title: '状态', align: 'center',width:50,formatter:function(value,row,index){
						if(value==0){
							return "未生效";	
						}else if(value==1){
							return "生效";
						}else if(value==2){
							return "失效";
						}else{
							return "";}
                      }
                    }
                ]
            ],
            onLoadSuccess:function(data){
                if (data.errorMsg){
                	$.messager.alert('错误',data.errorMsg);
                }
            },
            onLoadError:function(){
            	$.messager.alert('错误',"错误");
                   
            },
            toolbar: "#toolBar"
        });
    }
    function closeDetailWin(){
		$('#lotteryTicket_dialog').dialog('close');  
		doSearch();
	}
	//初始化 显示方式 
	function initShow() {
		$("#validDayStartId").hide();
		$("#validDayEndId").hide();
	}
	initShow();
	/* 查看 */
	function lookLink(){
		var row = $('#lotteryTicketDataGrid').datagrid('getSelected');
		if(row == null){
			$.messager.alert('提示',"请选中一条记录！");
		}else{
			lotteryTicketDetail(row.id,"SHOW","NO");	
		}
	}
	/* 修改  */
	function editLink(){
		var row = $('#lotteryTicketDataGrid').datagrid('getSelected');
		if(row == null){
			$.messager.alert('提示',"请选中一条记录！");
		}else{
			lotteryTicketDetail(row.id,"EDIT",row.approvalStatus);
		}
	}
	/* 优惠券  */
	function showUseTicket() {
		var row = $('#lotteryTicketDataGrid').datagrid('getSelected');
		if(row == null){
			$.messager.alert('提示',"请选中一条记录！");
		}else{
			if(row.type == 12){
				showIntegralUseDetail(row.id);
			}else{
				showUseTicketDetail(row.id,"SHOW",row.approvalStatus);
			}
			if(row.type == 13){
				showFreeTicket(row.id,"SHOW",row.approvalStatus);
			}else{
				showUseTicketDetail(row.id,"SHOW",row.approvalStatus);
			}
		}
	}
	function showFreeTicket(id,flag,status){

        if (id!=null&&id!=""){
        	$("#tempLtId").val(id);
            var url = '/lotteryTicket/goFreeTicketUseDetailList?id='+id+'&editFlag='+flag;
            $('#ticket_use_detail_dialog').html("<iframe width='1000' height='400' frameborder=0  src='"+url+"'></iframe>");
            $('#ticket_use_detail_dialog').dialog({
                title:'奖券列表',
                modal: true,
                width:'auto',
                height:'auto'
            });
        }
        
	}
	/* 删除  */
	function delLink() {
		var row = $('#lotteryTicketDataGrid').datagrid('getSelected');
		if(row == null){
			$.messager.alert('提示',"请选中一条记录！");
		}else{
			$.messager.confirm('提示', "是否删除该记录", function(r) {
	            if (r) {
	            	$.messager.progress({text:'执行中...'});
	            	$.post('<%=basePath%>/lotteryTicket/delTicket',{ltId:row.id},function(result){
	        	        if (result.code==-1){
	        	        	$.messager.progress('close');
	        	        	$.messager.alert('提示信息',result.msg);
	        	        } else {
	        	        	$.messager.progress('close');
	        	     	    $.messager.alert('提示信息',result.msg);
	        	     	  	doSearch();
	        	        }
	        	      }
	            	,'json');
	            }
	        });
		}
	}
	
	function borrowTypesClick(){
		var borrowTypes = "";
		if($("#borrowTypes1").attr("checked")){
			borrowTypes = "3"
		}
		if($("#borrowTypes2").attr("checked")){
			if(borrowTypes!=""){
				borrowTypes = borrowTypes+",1"
			}else{
				borrowTypes = "1"
			}
		}
		if($("#borrowTypes3").attr("checked")){
			if(borrowTypes!=""){
				borrowTypes = borrowTypes+",2"
			}else{
				borrowTypes = "2"
			}
		}
		if($("#borrowTypes4").attr("checked")){
			if(borrowTypes!=""){
				borrowTypes = borrowTypes+",0"
			}else{
				borrowTypes = "0"
			}
		}
		if($("#borrowTypes5").attr("checked")){
			if(borrowTypes!=""){
				borrowTypes = borrowTypes+",5"
			}else{
				borrowTypes = "5"
			}
		}
		if($("#borrowTypes6").attr("checked")){
			if(borrowTypes!=""){
				borrowTypes = borrowTypes+",6"
			}else{
				borrowTypes = "6"
			}
		}
		if($("#borrowTypes8").attr("checked")){
			if(borrowTypes!=""){
				borrowTypes = borrowTypes+",8"
			}else{
				borrowTypes = "8"
			}
		}
		if($("#borrowTypes9").attr("checked")){
			if(borrowTypes!=""){
				borrowTypes = borrowTypes+",9"
			}else{
				borrowTypes = "9"
			}
		}
		if($("#borrowTypes10").attr("checked")){
			if(borrowTypes!=""){
				borrowTypes = borrowTypes+",10"
			}else{
				borrowTypes = "10"
			}
		}
		$("#borrowTypes").val(borrowTypes);
	}
	
	function publishPlatformsClick(){
		var publishPlatforms = "";
		if($("#publishPlatforms1").attr("checked")){
			publishPlatforms = "1"
		}
		if($("#publishPlatforms2").attr("checked")){
			if(publishPlatforms!=""){
				publishPlatforms = publishPlatforms+",2"
			}else{
				publishPlatforms = "2"
			}
		}
		if($("#publishPlatforms3").attr("checked")){
			if(publishPlatforms!=""){
				publishPlatforms = publishPlatforms+",3"
			}else{
				publishPlatforms = "3"
			}
		}
		$("#publishPlatforms").val(publishPlatforms);
	}
	
	function borrowLoanPeriodsClick(){
		var borrowLoanPeriods = "";
		if($("#periods1").attr("checked")){
			borrowLoanPeriods = "3"
		}
		if($("#periods2").attr("checked")){
			if(borrowLoanPeriods!=""){
				borrowLoanPeriods = borrowLoanPeriods+",6"
			}else{
				borrowLoanPeriods = "6"
			}
		}
		if($("#periods3").attr("checked")){
			if(borrowLoanPeriods!=""){
				borrowLoanPeriods = borrowLoanPeriods+",12"
			}else{
				borrowLoanPeriods = "12"
			}
		}
		if($("#periods4").attr("checked")){
			if(borrowLoanPeriods!=""){
				borrowLoanPeriods = borrowLoanPeriods+",24"
			}else{
				borrowLoanPeriods = "24"
			}
		}
		$("#borrowLoanPeriods").val(borrowLoanPeriods);
	}
	function repaymentTypesClick(){
		var repaymentTypes = "";
		if($("#repaymentType1").attr("checked")){
			repaymentTypes = "3"
		}
		if($("#repaymentType2").attr("checked")){
			if(repaymentTypes!=""){
				repaymentTypes = repaymentTypes+",1"
			}else{
				repaymentTypes = "1"
			}
		}
		if($("#repaymentType3").attr("checked")){
			if(repaymentTypes!=""){
				repaymentTypes = repaymentTypes+",4"
			}else{
				repaymentTypes = "4"
			}
		}
		$("#repaymentTypes").val(repaymentTypes); 
	}
	
	function borrowLoanPeriodsInit(){
		if($("#borrowTypes3").attr("checked")){
			$("#periods1").attr("checked",true);
			$("#periods2").attr("checked",true);
			$("#periods3").attr("checked",true);
			$("#periods4").attr("checked",true);
			$("#borrowLoanPeriods_").show();
		}else{
			$("#periods1").attr("checked",false);
			$("#periods2").attr("checked",false);
			$("#periods3").attr("checked",false);
			$("#periods4").attr("checked",false);
			$("#borrowLoanPeriods_").hide();
		}
	}
	
	function borrowLoanPeriodsChangeCheck(){
		if(!$("#periods1").attr("checked") && !$("#periods2").attr("checked") && !$("#periods3").attr("checked") && !$("#periods4").attr("checked")){
			$("#borrowTypes3").attr("checked",false);
			$("#periods1").attr("checked",false);
			$("#periods2").attr("checked",false);
			$("#periods3").attr("checked",false);
			$("#periods4").attr("checked",false);
			$("#borrowLoanPeriods_").hide();
		}
	}
	function resetCheckbox(){
		$("#periods1").attr("checked",false);
		$("#periods2").attr("checked",false);
		$("#periods3").attr("checked",false);
		$("#periods4").attr("checked",false);
		$("#borrowLoanPeriods_").hide();
		$("#borrowTypes1").attr("checked",false);
		$("#borrowTypes2").attr("checked",false);
		$("#borrowTypes3").attr("checked",false);
		$("#borrowTypes5").attr("checked",false);
		$("#borrowTypes6").attr("checked",false);
		$("#borrowTypes8").attr("checked",false);
		$("#borrowTypes9").attr("checked",false);
		$("#borrowTypes10").attr("checked",false);
		$("#publishPlatforms").attr("checked",false);
		$("#publishPlatforms1").attr("checked",false);
		$("#publishPlatforms2").attr("checked",false);
		$("#publishPlatforms3").attr("checked",false);
		$('#addInterestDays').numberbox({required:false });
		$('#addInterestType').combobox('setValues','');
		$("#freeTicketType").combobox({ required: false });
		$('#freeTicketType').combobox('setValues','');
		$("#freeTicketValue").numberbox({ required: false });
		$("#freeTicketValue").val("");
	}
	
	function freeTicketInvest(){			
		 var termVal = $('#lotteryType').combobox('getValue');
    	if(termVal == 13){
    		$("#borrowTypes8").attr("checked",true);
    		$('#borrowTypes1').attr("disabled",true);
    		$('#borrowTypes2').attr("disabled",true);
    		$('#borrowTypes3').attr("disabled",true);
    		$('#borrowTypes4').attr("disabled",true);
    		$('#borrowTypes5').attr("disabled",true);
    		$('#borrowTypes6').attr("disabled",true);
    		$('#borrowTypes8').attr("disabled",true);
    		$('#borrowTypes9').attr("disabled",true);
    		$('#borrowTypes10').attr("disabled",true);
    	}else{
    		$('#borrowTypes1').attr("disabled",false);
    		$('#borrowTypes2').attr("disabled",false);
    		$('#borrowTypes3').attr("disabled",false);
    		$('#borrowTypes4').attr("disabled",false);
    		$('#borrowTypes5').attr("disabled",false);
    		$('#borrowTypes6').attr("disabled",false);
    		$('#borrowTypes8').attr("disabled",false);
    		$('#borrowTypes9').attr("disabled",false);
    		$('#borrowTypes10').attr("disabled",false);
    	} 
	}
	
	function validVal(){
		var freeTicketValue = $('#freeTicketValue').val();
		if(freeTicketValue>20){
			$('#freeTicketValue').numberbox('setValue','20');
		}else if(freeTicketValue<0.1){
			$('#freeTicketValue').numberbox('setValue','0.1');
		}
	}
	
	
	
</script>
</body>
</html>